import request from '@/utils/request'
// 创建学生考试
// export function createExam() {
//   return request({
//     url: '/student/exam/createExam/${id}',
//     method: 'post',
//
//   })


export function createExam(Id) {
  return request({
    url: `/course/exam/${Id}`,
    method: 'POST',
  }).then(response => {
    if (response.status === 200) {
      return response.data;
    } else {
      throw new Error('发布失败');
    }
  }).catch(error => {
    // 这里可以统一处理错误，例如弹出错误提示
    console.error("发布考试失败：", error);
    throw error;  // 抛出错误让调用者可以进一步处理
  });
}


// 查询考试列表
export function listExam(query) {
  return request({
    url: '/course/exam/list',
    method: 'get',
    params: query
  })
}

// 查询考试所有列表
export function listAllExam(query) {
  return request({
    url: '/course/exam/listAll',
    method: 'get',
    params: query
  })
}

// 查询考试详细
export function getExam(id) {
  return request({
    url: '/course/exam/getInfo/' + id,
    method: 'get'
  })
}

// 新增考试
export function addExam(data) {
  return request({
    url: '/course/exam/add',
    method: 'post',
    data: data
  })
}

// 修改考试
export function updateExam(data) {
  return request({
    url: '/course/exam/edit',
    method: 'post',
    data: data
  })
}

// 删除考试
export function delExam(id) {
  return request({
    url: '/course/exam/remove/' + id,
    method: 'get'
  })
}
